package com.ssy.lingxi.marketing.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 平台优惠券类型枚举
 * @author yzc
 * @version 2.0.0
 * @date 2021/6/28
 */
public enum PlatformCouponDetailStatusEnum {

    /**
     * 已领取 - 1
     */
    RECEIVE(1, "已领取"),

    /**
     * 已使用 - 2
     */
    USE(2, "已使用"),

    /**
     * 已过期 - 3
     */
    EXPIRE(3, "已过期");


    private final Integer code;
    private final String message;

    PlatformCouponDetailStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getCodeMessage(Integer code) {
        PlatformCouponDetailStatusEnum status = Arrays.stream(PlatformCouponDetailStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return status == null ? "未知" : status.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

}